/**
 * 表单回显处理数据
 * @param {*} numArr  [1,2,3,4,5,6,7]
 * @returns[星期日,...]
 */
export function toWeekendsArr(numArr) {
    return Array.isArray(numArr) && numArr.map((item, ind) => (
        toChinese(item)
    ))
}
/**
 * 提交表单处理数据
 * @param weekendArr  ['星期日']
 * @returns [1]
 */
export function toNumArr(weekendArr) {
    return Array.isArray(weekendArr) && weekendArr.map(item => toNum(item))
}

const toChinese = (num) => {
    let str = ''
    switch (num) {
        case 1:
            str = '星期日'
            break;
        case 2:
            str = '星期一'

            break;
        case 3:
            str = '星期二'

            break;
        case 4:
            str = '星期三'

            break;
        case 5:
            str = '星期四'

            break;
        case 6:
            str = '星期五'

            break;
        case 7:
            str = '星期六'

            break;

        default:
            break;
    }
    return str
}

const toNum = (str) => {
    let num = null
    switch (str) {
        case '星期日':
            num = 1
            break;
        case '星期一':
            num = 2

            break;
        case '星期二':
            num = 3

            break;
        case '星期三':
            num = 4

            break;
        case '星期四':
            num = 5

            break;
        case '星期五':
            num = 6

            break;
        case '星期六':
            num = 7

            break;

        default:
            break;
    }
    return num
}